package com.kangye.game.controller;

import com.alibaba.fastjson.JSON;
import com.kangye.game.pojo.Task;
import com.kangye.game.service.GameService;
import com.kangye.game.service.TaskService;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * @program: game
 * @description:
 * @author: lgk
 * @create: 2021-09-01 17:24
 **/
@RestController
@CrossOrigin
public class TaskController {
    @Resource(name ="ser")
    private GameService gameService;
    @Resource(name = "task")
    private TaskService taskService;
    @RequestMapping("FindAllTask.action")
    public Map<String,String> ad(String sa){
        Map<String,String>map=new HashMap<>();
        map.put("a",sa);
        String json= JSON.toJSONString(gameService.FindAllTask(map));
        Map<String,String> map1=new HashMap<>();
        map1.put("b",json);
        return map1;
    }
    @RequestMapping("FindTask.action")
    public Map<String,String>ads(int a){

        String json= JSON.toJSONString(taskService.FindTask(a));
        Map<String,String>map1=new HashMap<>();
        map1.put("b",json);
        return map1;
    }
    @RequestMapping("uptask")
    public  Map<String,String>  asdf(Task task){
        /*String json= JSON.toJSONString(taskService.uptask(task));*/
        int a=taskService.uptask(task);
        Map<String,String>map1=new HashMap<>();
        if(a>0){

            map1.put("b","200");
        }else {
            map1.put("b","400");
        }

        return map1;
    }

}
